package com.book.dao;


import static com.github.drinkjava2.jsqlbox.DB.pagin;

import java.util.List;

import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import com.book.entity.BookInfo;


/*
 * 
 * BookInfoDao类
 * 
 * 
 * 
 */




@Repository
@CacheConfig(cacheNames="HelloWorldCache")
public class BookInfoDao {
	/*
	 * 
	 *   	 
	 * 			返回最新的四本小说
	 * 
	 * 
	 */
	@Cacheable(key = "#root.methodName")
	public List<BookInfo> getLatestFour(){
		System.out.println("进入DAO查询最新四本小说方法");
		List<BookInfo> bookInfos = new BookInfo().findBySQL(" select * from book_info order by update_time desc",pagin(1, 4));
		return bookInfos;
		
	  }
	
	  /*
	   *    
	   * 
	   * 		返回点赞最多的八本小说
	   * 
	   * 
	   */
	@Cacheable(key = "#root.methodName")
	  public List<BookInfo> getZanEight(){
		System.out.println("进入DAO查询点赞最新八本小说方法");
			List<BookInfo> dianZanInfos  = new BookInfo().findBySQL(" select * from book_info order by dian_zan desc",pagin(1,8));
			return dianZanInfos;
 
		  
	  }
	

	
}
